package com.project.service;

import com.project.bean.UserBean;
import com.project.dao.IUserDao;
import com.project.server.Request;
import com.project.server.Response;
import com.project.uitl.DaoFactory;
import com.project.uitl.WebServlet;

@WebServlet("findById")
public class FindByIdService  implements Servlet {
    private IUserDao dao =(IUserDao) DaoFactory.getDao("IUserDao");

    public void service(Request request, Response response) {
        int id = Integer.parseInt(request.getParameter("id"));
        UserBean user = dao.findById(id);
        String str = "<form action='update'>";
        str += "<input type='hidden' name='id' value='" + id + "'>";
        str += "<p><span>用户名</span><span>" + user.getName() + "</span></p>";
        str += "<p><span>生日</span><span>" + user.getBirthday() + "</span></p>";
        str += "密码：<input type='text' value='" + user.getPwd() + "'name='pwd'<br>";
        str += "<input type='submit' value='修改'>";
        str += "</from>";
        response.sendMessage(str);
    }

}
